package com.ftp.web.spider.controller;

import com.ftp.web.spider.service.fileservice.PathFilesService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;

@Slf4j
@RestController
@RequestMapping(value = "/scan")
public class ScanPathContreller {

    private Logger logger= LoggerFactory.getLogger(ImgGetController.class);

    @Autowired
    private PathFilesService pathFilesService;

    @RequestMapping(method = RequestMethod.POST,value = "/filepath")
    @ResponseBody
    public String testClient(String path){
        System.out.println("链接成功");
        pathFilesService.addFilesInfo(new File(path));
        logger.info("----{}-----","参数");
        return "Success";
    }

    @RequestMapping(method = RequestMethod.GET,value = "/repeatshow")
    @ResponseBody
    public String showClient(){
        System.out.println("链接成功");
        pathFilesService.show();
        logger.info("----{}-----","参数");
        return "Success";
    }
}
